<template>
    <div class="app">
        <h1 class="title">美食</h1>
        <button class="button" @click="ViewFood">
            <img src="../assets/food.png" alt="美食图片" class="image">
        </button>
        
        <h1 class="title">笔记</h1>
        <button class="button" @click="ViewNote">
            <img src="../assets/note.jpg" alt="笔记图片" class="image">
        </button>
    </div>
</template>
<script>
export default{
    data()
    {
        return{
            userid:''
        }
    },
    methods:{
        ViewFood()
        {
            if(sessionStorage.getItem("userid"))
            {
                this.userid=sessionStorage.getItem("userid")
                this.$router.push({
                name:'food',
                query:this.userid
                })
            }else{
                alert("请先登录");
                this.$router.push({
                name:'login'
                
            })
            }
            
        },
        ViewNote()
        {
            if(sessionStorage.getItem("userid"))
            {
                this.userid=sessionStorage.getItem("userid")
                this.$router.push({
                name:'share',
                query:this.userid
                })
            }else{
                alert("请先登录");
                this.$router.push({
                name:'login'
                
            })
            }
        }
    }
}
</script>
<style>
    .app {
        display: float;
        max-width: 600px;
        margin: auto;
        text-align: center;
        padding: 20px;
    }

    .title {
        color: #333;
        font-size: 2em;
        margin-bottom: 20px;
    }

    .button {
        display: inline-block;
        background-color: #f1f1f1;
        border: none;
        padding: 10px 20px;
        margin: 10px;
        cursor: pointer;
        border-radius: 5px;
        transition: background-color 0.3s;
    }

    .button:hover {
        background-color: #ddd;
    }

    .image {
        width: 100%;
        height: auto;
        vertical-align: middle;
    }
</style>
